package com.oneonefive.trainticketsystem.controller;

import com.oneonefive.trainticketsystem.pojo.Refund;
import com.oneonefive.trainticketsystem.service.RefundService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
public class RefundController {
    final
    RefundService refundService;

    public RefundController(RefundService refundService) {
        this.refundService = refundService;
    }

    @RequestMapping("/insertRef")
    public void insertRefund(Integer refundId, Integer ticketId, String refundTime,Integer userId){
        refundService.insertOrUpdate( refundId,  ticketId,  refundTime, userId);
    }
    @RequestMapping("/deleteRef")
    public boolean deleteRef(Integer refundId){
        return refundService.removeById(refundId);
    }
    @RequestMapping("/selectRef")
    public List<Refund> selectRef(Integer refundId, Integer ticketId, Integer userId,Integer page){
        return refundService.selectAllRef( refundId,  ticketId, userId,page);
    }
    @RequestMapping("getRefRowCount")
    public int getRefRowCount(Integer refundId, Integer ticketId, Integer userId){
        return refundService.getRefRowCount( refundId,  ticketId,  userId);

    }
}
